<template>
  <div class='container'>
     <el-dialog
        title="题目审核"
        :visible="showCheckdialog"
        width="30%"
        @close="closeDialog"
        @open="openDialog"
        >
        <el-form ref='formRef' label-width="120px" :model="form" :rules="rules">
          <template>
            <el-radio v-model="form.chkState" label=1>通过</el-radio>
            <el-radio v-model="form.chkState" label=2>拒绝</el-radio>
          </template>
        <el-form-item prop="chkRemarks">
          <el-input
            style="margin-top:30px"
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            name="chkRemarks"
            v-model="form.chkRemarks">
          </el-input>
      </el-form-item>

          
        </el-form>
         <template #footer>
            <el-button @click="closeDialog">取 消</el-button>
            <el-button type="primary" @click="confirm">确 定</el-button>
         </template>
    </el-dialog>
  </div>
</template>

<script>
import {choiceCheck} from '@/api/hmmm/questions'
export default {
  props:{
    showCheckdialog:{
      type:Boolean
    }
  },
  data(){
    return {
      form:{
        id:'',
        chkState :null,
        chkRemarks:''
      },
      rules:{
        chkRemarks:[{ required: true, message: '请输入审核意见'}]
      }
    }
  },
  methods:{
    closeDialog(){
      this.$emit('close-checkdialog')
      this.form={
        chkState :null,
        chkRemarks:''
      }
    },
    openDialog(){
      
    },
     getId({id}){
      this.form.id=id
    },
    async confirm(){
      this.$refs.formRef.validate(async valid=>{
        if(valid){
        await choiceCheck({
        ...this.form,
        chkState:Number(this.form.chkState)
        })
        this.$emit('update-table')
        this.closeDialog()
        }else{
          this.$message.warning("请输入审核意见")
        } 
        
      })
     
    },
   
  }
}
</script>

<style scoped lang='less'></style>
